<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 创建子组件组件对象
    const CommonHead = {
      props:{
        // 只验证数据类型
        a: String,
        // 只验证类型 类型可以是给定多个类型中的一个
        b: [String,Number],
        c: {
          type: Number,
          required: true
        },
        d: {
          type: String,
          default: '我是默认值'
        },
        e: {
          type: Array,
          default: () => ['a','b','c','d']
        }
      }, 
      template:`
        <div>
          <h3>公共头部</h3>  
          {{a}}
          {{b}}
          {{c}}
          {{d}}
          <ul>
            <li v-for="item in e" :key="item">
              {{ item }}  
            </li>  
          </ul>
        </div>
      `
    }
    // 定义父组件
    const Home = {
      template: `
        <div>
          <h2>首页</h2>  
          <common-head a="都是我的无" :b="22" :c="111"></common-head>
        </div>
      `,
      data(){
        return {
          msg: 'home页动态数据'
        }
      },
      components: {
        CommonHead
      }
    }
    
    Vue.component('Home', Home);
    const vm = new Vue({
      // vm功能将vue语法渲染到 视图
      el: '#app'
    })
  </script>
</body>
</html>